package de.uni.muenster.idw2.location.wifi;


import java.net.URL;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/**
 * The class InfoParser starts a SaxParser which has the 
 * task to read out the info document placed on a given website
 * @author Michael Wilbers
 *
 */
public class InfoParser {
	
	
private final String urlString;
	
	public InfoParser(String url){
		this.urlString = url;
	}
	
	public void parse(){
		
		
		
		
		try{
			
			URL url = new URL(urlString);
			
			SAXParserFactory factory = SAXParserFactory.newInstance();
			
			SAXParser parser = factory.newSAXParser();
			System.out.println("was here");
			XMLReader reader = parser.getXMLReader();
			
			InfoHandler handler = new InfoHandler();
			
			reader.setContentHandler(handler);
			reader.parse(new InputSource(url.openStream()));
		}
		catch (Exception e){
			System.out.println("Fehler beim parsen");
		}
		
	}
	
}
